package edu.whu.demo.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.whu.demo.Vo.CommodityVo;
import edu.whu.demo.domain.Commodity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 王冠儒
 * @since 2023-10-22
 */
@Mapper
public interface CommodityDao extends BaseMapper<Commodity> {

    @Select("select * from commodity where ${ew.sqlSegment}")
    @Results({@Result(column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "id" ,
            property = "supplierIds" ,many=@Many(
            select = "edu.whu.demo.dao.SupplierDao.getSuppliersByCommodityId"
    ))
    })
    List<CommodityVo> getCommodityVos(@Param("ew") QueryWrapper wrapper);




}
